Click here for interactive plots:

https://kforthman.shinyapps.io/COVID19_Interactive_Plots/

Click here to see how cities and counties overlap:

https://kforthman.shinyapps.io/500citiescounties

Compare COVID stats to Neighborhood Factors

data.cor <- cor(county.Demo_and_Covid.allcounties[,-1], use = "complete.obs", method = "spearman")
corrplot.mixed(data.cor, upper = 'ellipse', lower = 'number', tl.pos = 'lt', tl.cex = 1, lower.col = "black", number.cex = 0.5)

Compare COVID stats to 500 cities data and Neighborhood Factors

data.cor2 <- cor(county.Demo_and_Covid.500counties[,-c(1:2)], use = "complete.obs", method = "spearman")
corrplot.mixed(data.cor2, upper = 'ellipse', lower = 'number', tl.pos = 'lt', tl.cex = 1, lower.col = "black", number.cex = 0.5)

corrplot.mixed(data.cor2[7:13,c(1:5, 14:42,6)], upper = 'ellipse', tl.pos = 'lt', tl.cex = 1, lower.col = "black", number.cex = 0.5)

—-Linear Mixed Effects Model —-

this.lme <- lmer("total.cases.percap ~ Affluence + Singletons.in.Tract + Seniors.in.Tract + African.Americans.in.Tract + Noncitizens.in.Tract + High.BP + Binge.Drinking + Cancer + Asthma + Heart.Disease + COPD + Smoking + Diabetes + No.Physical.Activity + Obesity + Poor.Sleeping.Habits + Poor.Mental.Health + Testing_Rate + Hospitalization_Rate + (1 | stateID)", data = county.Demo_and_Covid.500counties)
## Warning: Some predictor variables are on very different scales: consider
## rescaling

## Warning: Some predictor variables are on very different scales: consider
## rescaling
print(summary(this.lme), correlation=TRUE)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## "total.cases.percap ~ Affluence + Singletons.in.Tract + Seniors.in.Tract + African.Americans.in.Tract + Noncitizens.in.Tract + High.BP + Binge.Drinking + Cancer + Asthma + Heart.Disease + COPD + Smoking + Diabetes + No.Physical.Activity + Obesity + Poor.Sleeping.Habits + Poor.Mental.Health + Testing_Rate + Hospitalization_Rate + (1 | stateID)"
##    Data: county.Demo_and_Covid.500counties
## 
## REML criterion at convergence: -1272.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.3277 -0.3735 -0.0440  0.2666  5.7822 
## 
## Random effects:
##  Groups   Name        Variance    Std.Dev.
##  stateID  (Intercept) 0.000006139 0.002478
##  Residual             0.000015544 0.003943
## Number of obs: 192, groups:  stateID, 35
## 
## Fixed effects:
##                                  Estimate     Std. Error             df
## (Intercept)                 -0.0106730365   0.0117383172  99.6522998052
## Affluence                    0.0047825383   0.0011856547 145.0763321353
## Singletons.in.Tract          0.0009251830   0.0010045295 171.9763799445
## Seniors.in.Tract             0.0005189321   0.0013089203 171.6914089336
## African.Americans.in.Tract   0.0012167680   0.0011112903 171.9326569088
## Noncitizens.in.Tract         0.0017253193   0.0008579755 153.5283884113
## High.BP                      0.0000070266   0.0002120131 156.2000441759
## Binge.Drinking               0.0003594433   0.0002028032  73.6065252569
## Cancer                      -0.0020357477   0.0012679767 146.9532550504
## Asthma                       0.0001104857   0.0006835234  78.0008002594
## Heart.Disease                0.0028905515   0.0015902856 123.4821298686
## COPD                        -0.0001498570   0.0013112344 122.6011126894
## Smoking                     -0.0002067749   0.0002638750 138.5395917435
## Diabetes                    -0.0007862429   0.0006445205 125.9220623076
## No.Physical.Activity         0.0000313720   0.0002443292 137.0879757406
## Obesity                      0.0003719539   0.0002024264 162.9759143724
## Poor.Sleeping.Habits         0.0000861246   0.0001835164 159.5936574679
## Poor.Mental.Health          -0.0000602589   0.0005550160  50.9501886022
## Testing_Rate                 0.0000007601   0.0000002927  46.3396086292
## Hospitalization_Rate        -0.0001329402   0.0001234193  32.9280596003
##                            t value  Pr(>|t|)    
## (Intercept)                 -0.909    0.3654    
## Affluence                    4.034 0.0000885 ***
## Singletons.in.Tract          0.921    0.3583    
## Seniors.in.Tract             0.396    0.6923    
## African.Americans.in.Tract   1.095    0.2751    
## Noncitizens.in.Tract         2.011    0.0461 *  
## High.BP                      0.033    0.9736    
## Binge.Drinking               1.772    0.0805 .  
## Cancer                      -1.606    0.1105    
## Asthma                       0.162    0.8720    
## Heart.Disease                1.818    0.0715 .  
## COPD                        -0.114    0.9092    
## Smoking                     -0.784    0.4346    
## Diabetes                    -1.220    0.2248    
## No.Physical.Activity         0.128    0.8980    
## Obesity                      1.837    0.0680 .  
## Poor.Sleeping.Habits         0.469    0.6395    
## Poor.Mental.Health          -0.109    0.9140    
## Testing_Rate                 2.597    0.0126 *  
## Hospitalization_Rate        -1.077    0.2892    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of fixed effects could have been required in summary()
## 
## Correlation of Fixed Effects:
##             (Intr) Afflnc Sng..T Snr..T A.A..T Nnc..T Hgh.BP Bng.Dr Cancer
## Affluence    0.010                                                        
## Sngltns.n.T  0.023  0.068                                                 
## Snrs.n.Trct  0.474  0.345  0.190                                          
## Afrcn.Am..T  0.122  0.146 -0.388  0.147                                   
## Nnctzns.n.T  0.006  0.122  0.038  0.094 -0.126                            
## High.BP     -0.079  0.261  0.018  0.073 -0.067  0.342                     
## Bing.Drnkng -0.391 -0.121 -0.277 -0.116  0.063 -0.015  0.130              
## Cancer      -0.552 -0.103  0.211 -0.250 -0.077 -0.083 -0.334 -0.052       
## Asthma      -0.413 -0.096 -0.266 -0.211  0.077  0.095  0.117  0.040  0.041
## Heart.Dises -0.188  0.063 -0.310 -0.177  0.251 -0.137  0.058  0.067 -0.486
## COPD         0.578  0.004  0.162  0.267 -0.045  0.246  0.067  0.026 -0.255
## Smoking     -0.100  0.112 -0.178 -0.125 -0.045  0.063 -0.035 -0.280  0.082
## Diabetes     0.155 -0.384 -0.089 -0.192 -0.302 -0.233 -0.553  0.038  0.235
## N.Physcl.Ac -0.215  0.073  0.108  0.015 -0.018 -0.218 -0.007  0.120  0.442
## Obesity     -0.024  0.379  0.478  0.283  0.104  0.162 -0.100 -0.188  0.118
## Pr.Slpng.Hb -0.407 -0.391  0.112 -0.324 -0.278 -0.071 -0.184  0.110  0.094
## Pr.Mntl.Hlt -0.364  0.226 -0.053 -0.025  0.070 -0.118  0.026  0.122  0.349
## Testing_Rat  0.222 -0.148  0.025  0.007  0.011 -0.028 -0.043 -0.083 -0.170
## Hsptlztn_Rt -0.137 -0.127 -0.056 -0.180 -0.040 -0.114 -0.036 -0.076 -0.060
##             Asthma Hrt.Ds COPD   Smokng Diabts N.Ph.A Obesty Pr.S.H Pr.M.H
## Affluence                                                                 
## Sngltns.n.T                                                               
## Snrs.n.Trct                                                               
## Afrcn.Am..T                                                               
## Nnctzns.n.T                                                               
## High.BP                                                                   
## Bing.Drnkng                                                               
## Cancer                                                                    
## Asthma                                                                    
## Heart.Dises  0.328                                                        
## COPD        -0.409 -0.584                                                 
## Smoking      0.106  0.176 -0.465                                          
## Diabetes    -0.144 -0.360  0.012  0.212                                   
## N.Physcl.Ac  0.069 -0.342 -0.017 -0.289 -0.167                            
## Obesity     -0.210 -0.089  0.149 -0.253 -0.368 -0.003                     
## Pr.Slpng.Hb  0.089  0.257 -0.159 -0.079 -0.035 -0.155 -0.138              
## Pr.Mntl.Hlt -0.253  0.076 -0.451  0.021 -0.011  0.005  0.023 -0.126       
## Testing_Rat -0.297 -0.086  0.237  0.104  0.148 -0.299  0.081 -0.125 -0.150
## Hsptlztn_Rt  0.050  0.164 -0.131  0.083 -0.023  0.004  0.006  0.007 -0.089
##             Tstn_R
## Affluence         
## Sngltns.n.T       
## Snrs.n.Trct       
## Afrcn.Am..T       
## Nnctzns.n.T       
## High.BP           
## Bing.Drnkng       
## Cancer            
## Asthma            
## Heart.Dises       
## COPD              
## Smoking           
## Diabetes          
## N.Physcl.Ac       
## Obesity           
## Pr.Slpng.Hb       
## Pr.Mntl.Hlt       
## Testing_Rat       
## Hsptlztn_Rt  0.096
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
this.lme <- lmer("total.cases.percap ~ Affluence + Singletons.in.Tract + Seniors.in.Tract + African.Americans.in.Tract + Noncitizens.in.Tract + High.BP + Binge.Drinking + Cancer + Asthma + Heart.Disease + COPD + Smoking + Diabetes + No.Physical.Activity + Obesity + Poor.Sleeping.Habits + Poor.Mental.Health + (1 | stateID)", data = county.Demo_and_Covid.500counties)

print(summary(this.lme), correlation=TRUE)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## "total.cases.percap ~ Affluence + Singletons.in.Tract + Seniors.in.Tract + African.Americans.in.Tract + Noncitizens.in.Tract + High.BP + Binge.Drinking + Cancer + Asthma + Heart.Disease + COPD + Smoking + Diabetes + No.Physical.Activity + Obesity + Poor.Sleeping.Habits + Poor.Mental.Health + (1 | stateID)"
##    Data: county.Demo_and_Covid.500counties
## 
## REML criterion at convergence: -2415.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7752 -0.3992 -0.0629  0.2699  6.3971 
## 
## Random effects:
##  Groups   Name        Variance   Std.Dev.
##  stateID  (Intercept) 0.00000800 0.002828
##  Residual             0.00001385 0.003721
## Number of obs: 326, groups:  stateID, 51
## 
## Fixed effects:
##                                  Estimate     Std. Error             df
## (Intercept)                 -0.0236274032   0.0083089268 191.1636565760
## Affluence                    0.0032301089   0.0007568732 301.5429902594
## Singletons.in.Tract          0.0007626386   0.0007077702 301.6365993115
## Seniors.in.Tract             0.0009539135   0.0008937561 304.8211395708
## African.Americans.in.Tract   0.0020038355   0.0008637145 307.0311724146
## Noncitizens.in.Tract         0.0020407596   0.0006952358 269.8229467916
## High.BP                     -0.0000003537   0.0001561438 297.5998350371
## Binge.Drinking               0.0004645230   0.0001634060 156.6532558065
## Cancer                      -0.0006306463   0.0009148215 264.4285446262
## Asthma                       0.0006899500   0.0005413014 139.7260040998
## Heart.Disease                0.0034402502   0.0011719270 207.6078231000
## COPD                        -0.0014343905   0.0008870296 202.4492995936
## Smoking                     -0.0001334325   0.0002052925 247.7809563104
## Diabetes                    -0.0012931217   0.0004401860 266.9339650220
## No.Physical.Activity         0.0003053725   0.0001766569 234.9263053984
## Obesity                      0.0002837017   0.0001434690 307.9993641496
## Poor.Sleeping.Habits         0.0002474314   0.0001379948 296.5269083016
## Poor.Mental.Health          -0.0001692431   0.0004584917 102.4957980668
##                            t value  Pr(>|t|)    
## (Intercept)                 -2.844   0.00495 ** 
## Affluence                    4.268 0.0000265 ***
## Singletons.in.Tract          1.078   0.28211    
## Seniors.in.Tract             1.067   0.28668    
## African.Americans.in.Tract   2.320   0.02100 *  
## Noncitizens.in.Tract         2.935   0.00362 ** 
## High.BP                     -0.002   0.99819    
## Binge.Drinking               2.843   0.00507 ** 
## Cancer                      -0.689   0.49120    
## Asthma                       1.275   0.20456    
## Heart.Disease                2.936   0.00370 ** 
## COPD                        -1.617   0.10742    
## Smoking                     -0.650   0.51632    
## Diabetes                    -2.938   0.00360 ** 
## No.Physical.Activity         1.729   0.08519 .  
## Obesity                      1.977   0.04888 *  
## Poor.Sleeping.Habits         1.793   0.07398 .  
## Poor.Mental.Health          -0.369   0.71279    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of fixed effects could have been required in summary()
## 
## Correlation of Fixed Effects:
##             (Intr) Afflnc Sng..T Snr..T A.A..T Nnc..T Hgh.BP Bng.Dr Cancer
## Affluence   -0.047                                                        
## Sngltns.n.T -0.057  0.044                                                 
## Snrs.n.Trct  0.398  0.293  0.074                                          
## Afrcn.Am..T  0.242  0.076 -0.405  0.201                                   
## Nnctzns.n.T -0.072  0.153  0.126  0.057 -0.189                            
## High.BP     -0.096  0.157  0.099  0.007 -0.235  0.330                     
## Bing.Drnkng -0.486 -0.043 -0.206 -0.070  0.042 -0.076  0.149              
## Cancer      -0.496 -0.096  0.231 -0.174 -0.073 -0.068 -0.329 -0.021       
## Asthma      -0.267 -0.098 -0.262 -0.120 -0.011  0.210  0.055  0.006 -0.158
## Heart.Dises -0.057  0.075 -0.300 -0.132  0.212 -0.053 -0.003  0.034 -0.602
## COPD         0.479  0.012  0.127  0.173 -0.004  0.156  0.060  0.061 -0.214
## Smoking     -0.046  0.105 -0.119 -0.137 -0.105  0.160 -0.083 -0.327  0.159
## Diabetes     0.036 -0.300 -0.079 -0.133 -0.230 -0.256 -0.444  0.075  0.365
## N.Physcl.Ac -0.115  0.033  0.101  0.079  0.060 -0.274  0.004  0.124  0.338
## Obesity     -0.065  0.384  0.398  0.203  0.134  0.195 -0.104 -0.149  0.119
## Pr.Slpng.Hb -0.386 -0.352  0.163 -0.327 -0.322 -0.046 -0.156  0.087  0.029
## Pr.Mntl.Hlt -0.354  0.183 -0.007  0.019  0.050 -0.166  0.026  0.131  0.417
##             Asthma Hrt.Ds COPD   Smokng Diabts N.Ph.A Obesty Pr.S.H
## Affluence                                                          
## Sngltns.n.T                                                        
## Snrs.n.Trct                                                        
## Afrcn.Am..T                                                        
## Nnctzns.n.T                                                        
## High.BP                                                            
## Bing.Drnkng                                                        
## Cancer                                                             
## Asthma                                                             
## Heart.Dises  0.336                                                 
## COPD        -0.324 -0.489                                          
## Smoking      0.144  0.082 -0.476                                   
## Diabetes    -0.106 -0.430 -0.011  0.279                            
## N.Physcl.Ac -0.024 -0.361  0.087 -0.274 -0.169                     
## Obesity     -0.128 -0.021  0.092 -0.220 -0.377 -0.045              
## Pr.Slpng.Hb  0.000  0.240 -0.094 -0.165 -0.060 -0.154 -0.115       
## Pr.Mntl.Hlt -0.436 -0.067 -0.388 -0.027  0.073 -0.083  0.027 -0.083

Testing Rate

testing.data.state <- compiled.stats[[length(daily_filenames)]][, c("Province_State", "Testing_Rate")]
testing.data.state <- testing.data.state[!is.na(testing.data.state$Testing_Rate),]
testing.data.state <- testing.data.state[order(testing.data.state$Testing_Rate),]

col.state <- rep("pink", nrow(testing.data.state))

avg.test.rate <- mean(testing.data.state$Testing_Rate, na.rm = T)

col.state[testing.data.state$Testing_Rate < avg.test.rate] <- "grey"
col.state[testing.data.state$Province_State == "Oklahoma"] <- "lightblue"

par(mar = c(5,6,4,2))
barplot(testing.data.state$Testing_Rate, names.arg = testing.data.state$Province_State, horiz = T, main = "Testing Rate by State", las = 2, cex.axis = 1, cex.names = 0.5, col = col.state, border = F, xlab = "Total number of people tested per 100,000 persons.")
abline(v = avg.test.rate, col = "red")
text(x = avg.test.rate + 10, y = 1, labels = "Average Testing Rate", adj = c(0, 0.5), col = "red")

Pink highlights the last 14 days.

day.first.case <- min(which(US.total$cases.total > 100))
n.days <- nrow(US.total)

twoweek.col <- c(rep("grey", n.days-day.first.case-13), rep("pink", 14))

par(mar = c(5,5,4,2))
barplot(US.total$cases.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Total COVID-19 cases by Date in US", 
        las = 2, cex.axis = 1, cex.names = 0.5,
        col = twoweek.col, border = F)

barplot(US.total$cases.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Total COVID-19 cases by Date in US, log scale", 
        las = 2, cex.axis = 1, cex.names = 0.5, log = "y",
        col = twoweek.col, border = F)

barplot(US.total$deaths.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Total COVID-19 deaths by Date in US", 
        las = 2, cex.axis = 1, cex.names = 0.5,
        col = twoweek.col, border = F)

barplot(US.total$deaths.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Total COVID-19 deaths by Date in US, log scale", 
        las = 2, cex.axis = 1, cex.names = 0.5, log = "y",
        col = twoweek.col, border = F)

barplot(US.total$rise.cases.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Rise in Cases of COVID-19 by Date in US", 
        las = 2, cex.axis = 1, cex.names = 0.5,
        col = twoweek.col, border = F)

barplot(US.total$rise.deaths.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Rise in Deaths of COVID-19 by Date in US", 
        las = 2, cex.axis = 1, cex.names = 0.5,
        col = twoweek.col, border = F)